package cn.dnui_lf_705.dnui_16110100705.model;

import cn.dnui_lf_705.dnui_16110100705.iface.UserIface;
import cn.dnui_lf_705.dnui_16110100705.listener.OnRetrofitListener;
import cn.dnui_lf_705.dnui_16110100705.service.UserService;
import retrofit2.Call;

public class UserModel extends BaseModel implements UserIface {
    private UserService userService;

    public UserModel() {
        this.userService = retrofit.create(UserService.class);
    }

    @Override
    public void login(String username, String userpass, OnRetrofitListener listener) {
        Call call = userService.userLogin(username, userpass);
        bindCallback(call, listener, Constant.USERLOGIN);
    }

    @Override
    public void register(String username, String userpass, String mobilenum, String address, String comment, OnRetrofitListener listener) {
        Call call = userService.doregister(username, userpass, mobilenum, address, comment);
        bindCallback(call, listener, Constant.USEREGISTER);
    }

    public void userCollectFood(String user_id, String food_id, OnRetrofitListener listener) {
        Call call = userService.userCollectFood(user_id, food_id);
        bindCallback(call, listener, 6);
    }

    public void getAllUserCollection(String user_id, int flag, OnRetrofitListener listener) {
        Call call = userService.getAllUserCollection(user_id, flag);
        bindCallback(call, listener, 7);
    }

    public void userCollectShop(String user_id, String shop_id, OnRetrofitListener listener) {
        Call call = userService.userCollectShop(user_id, shop_id);
        bindCallback(call, listener, 8);
    }

    public void getUserById(String user_id, OnRetrofitListener listener) {
        Call call = userService.getUserById(user_id);
        bindCallback(call, listener, 9);
    }

    public void updateUserById(String user_id, String username, String userpass, String mobilenum, String address, OnRetrofitListener listener) {
        Call call = userService.updateUserById(user_id, username, userpass, mobilenum, address);
        bindCallback(call, listener, 10);
    }

    public void getAllOrdersByUser(String user_id, OnRetrofitListener listener) {
        Call call = userService.getAllOrdersByUser(user_id);
        bindCallback(call, listener, 11);
    }

    public void getAllCommentsByUser(String user_id, OnRetrofitListener listener) {
        Call call = userService.getAllCommentsByUser(user_id);
        bindCallback(call, listener, 12);
    }

    @Override
    public void updateComment(int order_id, String content, OnRetrofitListener listener) {
        Call call = userService.updateComment(order_id, content);
        bindCallback(call, listener, 13);
    }

    @Override
    public void deleteComment(int order_id, OnRetrofitListener listener) {
        Call call = userService.deleteComment(order_id);
        bindCallback(call, listener, 14);
    }

    public void insertComment(String item_id, String content, OnRetrofitListener listener) {
        Call call = userService.insertComment(item_id, content);
        bindCallback(call, listener, 15);
    }
}